# -*- coding: iso-8859-2 -*-

class RequotationType:
    '''
    Types of requotation:
    O - oryginal text
    R - requoted text
    '''
    
    NOT_SET = 0
    O = 1
    R = 2
    OR = 3
    RO = 4
    ORO = 5
    ROR = 6
    
    def __init__(self):
        self.pattern = ""
        
    def addLine(self, isOrginal):
        '''
        Add next line
        @param isOrginal line indicator
        '''
        if self.pattern == "":
            if (isOrginal):
                self.pattern = "O"
            else:
                self.pattern = "R"
            return
        
        if (isOrginal):
            if self.pattern[-1] == "R":
                self.pattern += "O"
        else:
            if self.pattern[-1] == "O":
                self.pattern += "R"
                
    def getType(self):
        '''
        @return type of the pattern
        '''
        
        if (self.pattern == ""):
            return 0
        if (self.pattern == "O"):
            return 1
        if (self.pattern == "R"):
            return 2
        if (self.pattern == "OR"):
            return 3
        if (self.pattern == "RO"):
            return 4
        if (self.pattern[:3] == "ORO"):
            return 5
        if (self.pattern[:3] == "ROR"):
            return 6
        
        return 0
    
if __name__ == "__main__":
     r = RequotationType()
     r.addLine(False)
     r.addLine(True)
     r.addLine(True)
     r.addLine(True)
     r.addLine(False)
     r.addLine(False)
     r.addLine(True)
     r.addLine(True)
     r.addLine(False)
     r.addLine(True)
        
     print r.getType()
    
